// pages/Order/Order.js
Page({

  /**slider组件按钮点击事件传递回来,根据状态,来设置数据源 */
    onMyEvent:function(e){
      
      console.log(e.detail)
      let id = e.detail.id
      var orderArr = new Array()
      
      if(id == 1){
  
        orderArr = JSON.parse(JSON.stringify(this.data.finishList))
      
      }else{
  
        orderArr = JSON.parse(JSON.stringify(this.data.orderList))
      }
  
  
      this.setData({
        orderData:orderArr,
        curId:id
      })
    },
    /**
     * 页面的初始数据
     */
    data: {
  
      scrollHeight: 1,
      curId: 0,/**当前选中的状态 */

      // 

      active: [

        { id: 0, name: '进行中' },
        { id: 1, name: '已完成' }
      ],/**用于slider组件的布局传值 */

      orderData: [],/**数据源,orderList和finishLis是用来模拟切换状态时数据源的切换 */

      orderList: [
        {
          orderNum: '订单号: 1234567890',
          orderStatus: '进行中',
          carList: [

            {
              name: '奥迪A4 奢侈款 ',
              date: '2020-3-12 20:00:00',
              num: '数量: 10/6',
              decorate: '外饰/内饰:黑色/灰色',
              
            }
          ],
          provider: '供应商:上海汽车租赁公司'
        },
        {

          orderNum: '订单号: 123456789',
          orderStatus: '进行中',
          carList: [

            {
              name: '奔驰A4 奢侈款 ',
              date: '2020-3-12 20:00:00',
              num: '数量: 10/6',
              decorate: '外饰/内饰:黑色/灰色',
              
            },
            {
              name: '别克 奢侈款',
              date: '2020-3-12 20:00:00',
              num: '数量: 10/6',
              decorate: '外饰/内饰:黑色/灰色',
              
            }
          ],
          provider: '供应商:上海汽车租赁公司'
        },
        {
          orderNum: '订单号: 123456789',
          orderStatus: '进行中',
          carList: [

            {
              name: '兰博基尼 奢侈款',
              date: '2020-3-12 20:00:00',
              num: '数量: 20/6',
              decorate: '外饰/内饰:黑色/灰色',
              
            },
            {
              name: '悍马 奢侈款',
              date: '2020-3-12 20:00:00',
              num: '数量: 12/6',
              decorate: '外饰/内饰:黑色/灰色',
              
            },
            {
              name: '雪佛兰 奢侈款',
              date: '2020-3-12 20:00:00',
              num: '数量: 12/6',
              decorate: '外饰/内饰:黑色/灰色',
              
            }
          ],
          provider: '供应商:上海汽车租赁公司'
        }
      ],


      finishList: [

        {
          orderNum: '订单号: 1234567890',
          orderStatus: '交易完成',
          carList: [

            {
              name: '本田 ',
              date: '2020-3-12 20:00:00',
              num: '数量: 10/6',
              decorate: '外饰/内饰:黑色/灰色',
              record: [
                {
                  recordName: '黎明',
                  recordNum: '(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                },
                {
                  recordName: '郭富城',
                  recordNum: '(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                }
              ]
            }
          ],
          provider: '供应商:上海汽车租赁公司'
        },
        {

          orderNum: '订单号: 123456789',
          orderStatus: '交易完成',
          carList: [

            {
              name: '一汽大众 奢侈款',
              date: '2020-3-12 20:00:00',
              num: '数量: 10/6',
              decorate: '外饰/内饰:黑色/灰色',
              record: [
                {
                  recordName: '黎明',
                  recordNum: '(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                },
                {
                  recordName: '郭富城',
                  recordNum: '(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                }
              ]
            },
            {
              name: '齐瑞QQ 奢侈款',
              date: '2020-3-12 20:00:00',
              num: '数量: 10/6',
              decorate: '外饰/内饰:黑色/灰色',
              record: [
                {
                  recordName: '黎明',
                  recordNum: '(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                },
                {
                  recordName: '郭富城',
                  recordNum: '(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                }
              ]

            }
          ],
          provider: '供应商:上海汽车租赁公司'
        },
        {
          orderNum: '订单号: 123456789',
          orderStatus: '交易完成',
          carList: [


            {
              name: '凯迪拉克 奢侈款',
              date: '2020-3-12 20:00:00',
              num: '数量: 20/6',
              decorate: '外饰/内饰:黑色/灰色',
              record:[
                {
                  recordName: '黎明',
                  recordNum:'(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                },
                {
                  recordName: '郭富城',
                  recordNum: '(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                }
              ]
            },
            ,
            {
              name: '辉腾 奢侈款 ',
              date: '2020-3-12 20:00:00',
              num: '数量: 12/6',
              decorate: '外饰/内饰:黑色/灰色',
              record: [
                {
                  recordName: '黎明',
                  recordNum: '(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                },
                {
                  recordName: '郭富城',
                  recordNum: '(数量3)',
                  recordDate: '2020-04-02 16:48:32'
                }
              ]
            }
          ],
          provider: '供应商:上海汽车租赁公司'
        }
      ]
    },
  
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
  
      let statusBarHeight = wx.getSystemInfoSync().statusBarHeight
      console.log(wx.getSystemInfoSync().windowHeight)
      this.setData({

        scrollHeight: wx.getSystemInfoSync().windowHeight - 55

      })
    },
   
    
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
  
    },
  
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
  
      this.setData({
        orderData: this.data.orderList
      })

     

    },
  
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
  
    },
  
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
  
    },
  
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
  
    },
  
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
  
    },
  
    /**
     * 用户点击右上角分享
     */
  
    onShareAppMessage: function () {
  
    },

  orderClick: function(){

    wx.navigateTo({
      url: 'transDetail',
    })
  }
    
  })
  